3.11.74 \(\int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx\) [1074]

Optimal. Leaf size=75 \[ \frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i d^2 \log (\cos (e+f x))}{a f}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))} \]

[Out]

1/2*(c^2-2*I*c*d+d^2)*x/a+I*d^2*ln(cos(f*x+e))/a/f+1/2*I*(c+I*d)^2/f/(a+I*a*tan(f*x+e))

________________________________________________________________________________________

Rubi [A]
time = 0.06, antiderivative size = 75, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 28, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.071, Rules used = {3621, 3556} \begin {gather*} \frac {x \left (c^2-2 i c d+d^2\right )}{2 a}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}+\frac {i d^2 \log (\cos (e+f x))}{a f} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(c + d*Tan[e + f*x])^2/(a + I*a*Tan[e + f*x]),x]

[Out]

((c^2 - (2*I)*c*d + d^2)*x)/(2*a) + (I*d^2*Log[Cos[e + f*x]])/(a*f) + ((I/2)*(c + I*d)^2)/(f*(a + I*a*Tan[e +
f*x]))

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3621

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^2, x_Symbol] :> Simp[(
-b)*(a*c + b*d)^2*((a + b*Tan[e + f*x])^m/(2*a^3*f*m)), x] + Dist[1/(2*a^2), Int[(a + b*Tan[e + f*x])^(m + 1)*
Simp[a*c^2 - 2*b*c*d + a*d^2 - 2*b*d^2*Tan[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a
*d, 0] && LeQ[m, -1] && EqQ[a^2 + b^2, 0]

Rubi steps

\begin {align*} \int \frac {(c+d \tan (e+f x))^2}{a+i a \tan (e+f x)} \, dx &=\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}+\frac {\int \left (a \left (c^2-2 i c d+d^2\right )-2 i a d^2 \tan (e+f x)\right ) \, dx}{2 a^2}\\ &=\frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}-\frac {\left (i d^2\right ) \int \tan (e+f x) \, dx}{a}\\ &=\frac {\left (c^2-2 i c d+d^2\right ) x}{2 a}+\frac {i d^2 \log (\cos (e+f x))}{a f}+\frac {i (c+i d)^2}{2 f (a+i a \tan (e+f x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(155\) vs. \(2(75)=150\).
time = 1.01, size = 155, normalized size = 2.07 \begin {gather*} \frac {c^2+2 i c d-d^2-2 i c^2 f x-4 c d f x+2 i d^2 f x+2 d^2 \log \left (\cos ^2(e+f x)\right )+\left (d^2 (i-2 f x)+c^2 (-i+2 f x)+2 c (d-2 i d f x)+2 i d^2 \log \left (\cos ^2(e+f x)\right )\right ) \tan (e+f x)+4 d^2 \text {ArcTan}(\tan (f x)) (-i+\tan (e+f x))}{4 a f (-i+\tan (e+f x))} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(c + d*Tan[e + f*x])^2/(a + I*a*Tan[e + f*x]),x]

[Out]

(c^2 + (2*I)*c*d - d^2 - (2*I)*c^2*f*x - 4*c*d*f*x + (2*I)*d^2*f*x + 2*d^2*Log[Cos[e + f*x]^2] + (d^2*(I - 2*f
*x) + c^2*(-I + 2*f*x) + 2*c*(d - (2*I)*d*f*x) + (2*I)*d^2*Log[Cos[e + f*x]^2])*Tan[e + f*x] + 4*d^2*ArcTan[Ta
n[f*x]]*(-I + Tan[e + f*x]))/(4*a*f*(-I + Tan[e + f*x]))

________________________________________________________________________________________

Maple [A]
time = 0.24, size = 93, normalized size = 1.24

method result size
derivativedivides \(\frac {\left (-\frac {1}{2} c d -\frac {1}{4} i c^{2}-\frac {3}{4} i d^{2}\right ) \ln \left (\tan \left (f x +e \right )-i\right )-\frac {-i c d -\frac {1}{2} c^{2}+\frac {1}{2} d^{2}}{\tan \left (f x +e \right )-i}-\frac {i \left (2 i c d -c^{2}+d^{2}\right ) \ln \left (\tan \left (f x +e \right )+i\right )}{4}}{f a}\) \(93\)
default \(\frac {\left (-\frac {1}{2} c d -\frac {1}{4} i c^{2}-\frac {3}{4} i d^{2}\right ) \ln \left (\tan \left (f x +e \right )-i\right )-\frac {-i c d -\frac {1}{2} c^{2}+\frac {1}{2} d^{2}}{\tan \left (f x +e \right )-i}-\frac {i \left (2 i c d -c^{2}+d^{2}\right ) \ln \left (\tan \left (f x +e \right )+i\right )}{4}}{f a}\) \(93\)
risch \(-\frac {i x c d}{a}+\frac {c^{2} x}{2 a}+\frac {3 x \,d^{2}}{2 a}-\frac {{\mathrm e}^{-2 i \left (f x +e \right )} c d}{2 a f}+\frac {i {\mathrm e}^{-2 i \left (f x +e \right )} c^{2}}{4 a f}-\frac {i {\mathrm e}^{-2 i \left (f x +e \right )} d^{2}}{4 a f}+\frac {2 d^{2} e}{a f}+\frac {i d^{2} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}{a f}\) \(126\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x,method=_RETURNVERBOSE)

[Out]

1/f/a*((-1/2*c*d-1/4*I*c^2-3/4*I*d^2)*ln(tan(f*x+e)-I)-(-I*c*d-1/2*c^2+1/2*d^2)/(tan(f*x+e)-I)-1/4*I*(2*I*c*d-
c^2+d^2)*ln(tan(f*x+e)+I))

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

Fricas [A]
time = 1.13, size = 88, normalized size = 1.17 \begin {gather*} \frac {{\left (2 \, {\left (c^{2} - 2 i \, c d + 3 \, d^{2}\right )} f x e^{\left (2 i \, f x + 2 i \, e\right )} + 4 i \, d^{2} e^{\left (2 i \, f x + 2 i \, e\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right ) + i \, c^{2} - 2 \, c d - i \, d^{2}\right )} e^{\left (-2 i \, f x - 2 i \, e\right )}}{4 \, a f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="fricas")

[Out]

1/4*(2*(c^2 - 2*I*c*d + 3*d^2)*f*x*e^(2*I*f*x + 2*I*e) + 4*I*d^2*e^(2*I*f*x + 2*I*e)*log(e^(2*I*f*x + 2*I*e) +
 1) + I*c^2 - 2*c*d - I*d^2)*e^(-2*I*f*x - 2*I*e)/(a*f)

________________________________________________________________________________________

Sympy [A]
time = 0.26, size = 170, normalized size = 2.27 \begin {gather*} \begin {cases} \frac {\left (i c^{2} - 2 c d - i d^{2}\right ) e^{- 2 i e} e^{- 2 i f x}}{4 a f} & \text {for}\: a f e^{2 i e} \neq 0 \\x \left (- \frac {c^{2} - 2 i c d + 3 d^{2}}{2 a} + \frac {\left (c^{2} e^{2 i e} + c^{2} - 2 i c d e^{2 i e} + 2 i c d + 3 d^{2} e^{2 i e} - d^{2}\right ) e^{- 2 i e}}{2 a}\right ) & \text {otherwise} \end {cases} + \frac {i d^{2} \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{a f} + \frac {x \left (c^{2} - 2 i c d + 3 d^{2}\right )}{2 a} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))**2/(a+I*a*tan(f*x+e)),x)

[Out]

Piecewise(((I*c**2 - 2*c*d - I*d**2)*exp(-2*I*e)*exp(-2*I*f*x)/(4*a*f), Ne(a*f*exp(2*I*e), 0)), (x*(-(c**2 - 2
*I*c*d + 3*d**2)/(2*a) + (c**2*exp(2*I*e) + c**2 - 2*I*c*d*exp(2*I*e) + 2*I*c*d + 3*d**2*exp(2*I*e) - d**2)*ex
p(-2*I*e)/(2*a)), True)) + I*d**2*log(exp(2*I*f*x) + exp(-2*I*e))/(a*f) + x*(c**2 - 2*I*c*d + 3*d**2)/(2*a)

________________________________________________________________________________________

Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 131 vs. \(2 (63) = 126\).
time = 0.56, size = 131, normalized size = 1.75 \begin {gather*} -\frac {\frac {{\left (i \, c^{2} + 2 \, c d + 3 i \, d^{2}\right )} \log \left (\tan \left (f x + e\right ) - i\right )}{a} + \frac {{\left (-i \, c^{2} - 2 \, c d + i \, d^{2}\right )} \log \left (i \, \tan \left (f x + e\right ) - 1\right )}{a} + \frac {-i \, c^{2} \tan \left (f x + e\right ) - 2 \, c d \tan \left (f x + e\right ) - 3 i \, d^{2} \tan \left (f x + e\right ) - 3 \, c^{2} - 2 i \, c d - d^{2}}{a {\left (\tan \left (f x + e\right ) - i\right )}}}{4 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((c+d*tan(f*x+e))^2/(a+I*a*tan(f*x+e)),x, algorithm="giac")

[Out]

-1/4*((I*c^2 + 2*c*d + 3*I*d^2)*log(tan(f*x + e) - I)/a + (-I*c^2 - 2*c*d + I*d^2)*log(I*tan(f*x + e) - 1)/a +
 (-I*c^2*tan(f*x + e) - 2*c*d*tan(f*x + e) - 3*I*d^2*tan(f*x + e) - 3*c^2 - 2*I*c*d - d^2)/(a*(tan(f*x + e) -
I)))/f

________________________________________________________________________________________

Mupad [B]
time = 5.62, size = 112, normalized size = 1.49 \begin {gather*} -\frac {\frac {c\,d}{a}-\frac {c^2\,1{}\mathrm {i}}{2\,a}+\frac {d^2\,1{}\mathrm {i}}{2\,a}}{f\,\left (1+\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (c^2-c\,d\,2{}\mathrm {i}+3\,d^2\right )\,1{}\mathrm {i}}{4\,a\,f}+\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (c^2\,1{}\mathrm {i}+2\,c\,d-d^2\,1{}\mathrm {i}\right )}{4\,a\,f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((c + d*tan(e + f*x))^2/(a + a*tan(e + f*x)*1i),x)

[Out]

(log(tan(e + f*x) + 1i)*(2*c*d + c^2*1i - d^2*1i))/(4*a*f) - (log(tan(e + f*x) - 1i)*(c^2 - c*d*2i + 3*d^2)*1i
)/(4*a*f) - ((d^2*1i)/(2*a) - (c^2*1i)/(2*a) + (c*d)/a)/(f*(tan(e + f*x)*1i + 1))

________________________________________________________________________________________